<template>
  <div class="checkBox">
    <span 
      v-for="(item, index) in label"
      :key="item"
      @click="check(index)"
      class="btm"
      :style="{
        background:
          current == index ? props.color[0] : props.color[1],
        color: current == index ? props.color[1] : props.color[0],
      }">
      {{ label[index] }}
    </span>
  </div>
</template>

<script lang="ts" setup>
import {ref,defineProps,defineEmits} from 'vue'

let props =defineProps({
    label: {
      type: Array,
      default: () => {},
    },
    color:{
          type: Array,
      default: () => {return ["#1890FF","#ffffff"]},
    }
})
let emit =defineEmits(['upCurrent'])
let current =ref(0)
function check(val){
current.value = val
emit('upCurrent',current.value)
}
</script>
<style scoped lang="scss">
.checkBox{
  border: 1px solid #1890ff;
  border-radius: 5px;
  width: 200px;
  box-sizing: border-box;
}
.btm {
  z-index: 9999;
  height: 100%;
  flex: 1;
  display: inline-block;
  width: 50%;
  padding: 0 5px;
  border-radius: 2px;
  display: inline-block;
  vertical-align: middle;
  // border-right: 1px solid #fff;
  margin-bottom: 0;
  font-size: 16px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  line-height: 30px;
  cursor: pointer;
  text-align: center;
  // background: #FAF0FF;
  // border-radius: 2px;
  box-sizing: border-box;

}
:nth-last-child(1) .btm{
// border: none;
}
</style>